local matRefraction	= Material( "refract_ring" )

local tMats = {}

tMats.Glow1 = Material("models/roller/rollermine_glow")
tMats.Glow2 = Material("sprites/yellowflare")
tMats.Glow3 = Material("sprites/redglow2")


/*---------------------------------------------------------
   Init( data table )
---------------------------------------------------------*/
function EFFECT:Init( data )

	self.Position = data:GetOrigin()
	self.Position.z = self.Position.z + 4
	self.TimeLeft = CurTime() + 7.6
	self.GAlpha = 25
	self.GSize = 5
	self.CloudHeight = data:GetScale()
	
	self.Refract = 0
	self.Size = 12
	if render.GetDXLevel() <= 81 then
		matRefraction = Material( "effects/strider_pinch_dudv" )
	end
	
	self.SplodeDist = 7
	self.BlastSpeed = 35
	self.lastThink = 0
	self.MinSplodeTime = CurTime() + self.CloudHeight/self.BlastSpeed
	self.MaxSplodeTime = CurTime() + 6
	self.GroundPos = self.Position - Vector(0,0,self.CloudHeight)
	
	local Pos = self.Position
	
	
	self.smokeparticles = {}
	self.Emitter = ParticleEmitter( Pos )
	self.vecang = VectorRand()
	
end

/*---------------------------------------------------------
   THINK
---------------------------------------------------------*/
function EFFECT:Think( )

	
	

	local Pos = self.Position
	local timeleft = self.TimeLeft - CurTime()
	if timeleft > 0 then 
		local ftime = FrameTime()
		
		self.GAlpha = self.GAlpha - 10.5*ftime
		self.GSize = self.GSize - 0.12*timeleft*ftime
		
		self.Size = self.Size + 1200*ftime
		self.Refract = self.Refract + 2.3*ftime
		
		--shock ring
		if (self.Size < 80) then
			local spawndist = self.Size
			local NumPuffs = spawndist / 45
			
				
			local ang = self.vecang:Angle()
			for i=1, NumPuffs do
					
		
					ang:RotateAroundAxis(ang:Up(), (360/NumPuffs))
					local newang = ang:Forward()
					local spawnpos = (Pos + (newang * spawndist))
					local particle = self.Emitter:Add( "particles/flamelet"..math.random(1,5), spawnpos)
		--			particle:SetVelocity(vecang*math.Rand(2,3))
					particle:SetVelocity(Vector(0, 0, 0))
					particle:SetDieTime( 2 )
					particle:SetStartAlpha( math.Rand(230, 250) )
					particle:SetStartSize( 20*math.Rand( 4, 6 ) )
					particle:SetEndSize( math.Rand( 2, 3 ) )
					particle:SetRoll( math.Rand( 20, 80 ) )
					particle:SetRollDelta( math.random( -1, 1 ) )
					particle:SetColor(20, math.random(20,60), math.random(100,255))
					particle:VelocityDecay( true )
			
			end
					ang:RotateAroundAxis(ang:Forward(), (360/NumPuffs))
					local newang = ang:Up()
					local spawnpos = (Pos + (newang * spawndist))
					local particle2 = self.Emitter:Add( "particles/flamelet"..math.random(1,5), spawnpos)
		--			particle:SetVelocity(vecang*math.Rand(2,3))
					particle2:SetVelocity(Vector(0, 0, 0))
					particle2:SetDieTime( 2 )
					particle2:SetStartAlpha( math.Rand(230, 250) )
					particle2:SetStartSize( 20*math.Rand( 4, 6 ) )
					particle2:SetEndSize( math.Rand( 2, 3 ) )
					particle2:SetRoll( math.Rand( 20, 80 ) )
					particle2:SetRollDelta( math.random( 100, 250 ) )
					particle2:SetColor(20, math.random(20,60), math.random(100,255))
					particle2:VelocityDecay( true )
		end
		
		
		return true
	else
		self.Emitter:Finish()
		return false	
	end

end

/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render( )
end
